home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
7661
/
7661.xpi
/
components
/
RILprefs.js
< prev
next >
Wrap
Text File
|
2009-12-23
|
5KB
|
191 lines
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function RILprefs() {
this.wrappedJSObject = this;
this.PREFS = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService).getBranch("isreaditlater.");
}
// class definition
RILprefs.prototype = {
// properties required for XPCOM registration:
classDescription: "Read It Later Prefs Javascript XPCOM Component",
classID: Components.ID("{dfad9f70-aaaf-11de-8a39-0800200c9a66}"),
contractID: "@ril.ideashower.com/rilprefs;1",
QueryInterface: XPCOMUtils.generateQI(),
//////////////////////////////////
// Save prefs
set : function(name, value)
{
switch( typeof value )
{
case('boolean'):
try{
this.PREFS.setBoolPref(name, value);
break;
} catch(e) {
try {
this.remove(name);
this.PREFS.setBoolPref(name, value);
break;
} catch(e)
{
Components.utils.reportError('Error saving pref: '+name+' = '+value);
Components.utils.reportError(e);
}
}
// There are int prefs, but for compatibility reasons, do not use them
default:
this.PREFS.setCharPref(name, value);
break;
}
},
isSet : function(name)
{
return this.PREFS.prefHasUserValue(name);
},
setIfDoesNotExist : function(name, value)
{
if (!this.isSet(name))
{
this.set(name, value);
}
},
rename : function(oldName, newName) {
this.set(newName, this.get(oldName));
this.remove(op);
},
remove : function(name)
{
if (this.isSet(name))
{
this.set(name, '');
return this.PREFS.clearUserPref(name);
}
},
append : function(name, value)
{
return this.PREFS.setCharPref(name, this.get(name) + value);
},
// Get
get : function(name) {
if (this.isSet(name)) return this.PREFS.getCharPref(name);
},
getBool : function(name)
{
if (this.isSet(name)) {
try {
return this.PREFS.getBoolPref(name);
} catch(e) {
return this.PREFS.getCharPref(name) == 'true' ? true : false;
}
}
},
loadDefaults : function()
{
//Installation
this.setIfDoesNotExist("installed", (this.isSet('version')) );
this.setIfDoesNotExist("version", '');
this.setIfDoesNotExist("toolbar-btn-added", false);
this.setIfDoesNotExist("install-version", '0');
//Reading/Saving
this.setIfDoesNotExist("read", 'list');
this.setIfDoesNotExist("mark", 'null');
this.setIfDoesNotExist("open", 'current');
this.setIfDoesNotExist("autoMark", false);
this.setIfDoesNotExist("autoCloseTab", false);
//Appearance
this.setIfDoesNotExist("context-menu", true);
this.setIfDoesNotExist("list-view", 'normal');
this.setIfDoesNotExist("list-place", 'btn');
this.setIfDoesNotExist("list-type", 'pages');
this.setIfDoesNotExist("list-page", 9);
this.setIfDoesNotExist("default-sort", 0);
this.setIfDoesNotExist("show-count", false);
this.setIfDoesNotExist("show-date", false);
this.setIfDoesNotExist("force-styles", true);
this.setIfDoesNotExist("showStatusIconText", 'item');
this.setIfDoesNotExist("showStatusIconShare", 'item');
this.setIfDoesNotExist("showStatusIconClick", 'hide');
//Keystrokes
this.setIfDoesNotExist("hotkey_toggle", 'alt||W');
this.setIfDoesNotExist("hotkey_push", 'alt||P');
this.setIfDoesNotExist("hotkey_open_list", 'alt||Q');
this.setIfDoesNotExist("hotkey_click_mode", 'alt||M');
this.setIfDoesNotExist("hotkey_sidebar", 'alt||[');
this.setIfDoesNotExist("hotkey_gr", 'i');
//Syncing
this.setIfDoesNotExist("since", '0');
this.setIfDoesNotExist("autoSync", true);
this.setIfDoesNotExist('storeSecurely', true);
this.setIfDoesNotExist('promptedAboutMasterPass',false);
//Text
this.setIfDoesNotExist("text-options", JSON.stringify({
L: 0,
S: 1,
F: 1,
M: 1,
A: 1
}));
//Google Reader
this.setIfDoesNotExist("integrate-gr", true);
//Prompt Windows
this.setIfDoesNotExist("prompt_clear_offline",true);
//Offline
this.setIfDoesNotExist('getOfflineWeb', true);
this.setIfDoesNotExist('getOfflineText', false);
this.setIfDoesNotExist("autoOffline", false);
}
};
var components = [RILprefs];
function NSGetModule(compMgr, fileSpec) {
return XPCOMUtils.generateModule(components);
}